#!/usr/bin/env python3
"""MBI Efficacy Analysis Script
Author: Juan Moises de la Serna
"""
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

df = pd.read_csv('clinical_studies.csv')
df['pct_reduction'] = (df['anxiety_pre_mean'] - df['anxiety_post_mean']) / df['anxiety_pre_mean'] * 100

print(df.groupby('intervention_type')['effect_size_d'].describe())
print("\nMean anxiety reduction (%):", df['pct_reduction'].mean().round(1))

plt.bar(df['study_id'], df['effect_size_d'], color='steelblue')
plt.axhline(0.5, linestyle='--', color='orange', label='Medium effect')
plt.title('Cohen d by Study')
plt.xlabel('Study ID')
plt.ylabel("Cohen's d")
plt.legend()
plt.xticks(rotation=45)
plt.tight_layout()
plt.savefig('effect_sizes.png', dpi=150)
